package com.li.youhappygo.controller;

import com.github.pagehelper.PageInfo;
import com.li.youhappygo.model.vo.common.Result;
import com.li.youhappygo.model.vo.common.ResultCode;
import com.li.youhappygo.model.vo.customer.CustomerDetailVo;
import com.li.youhappygo.model.vo.customer.CustomerVo;
import com.li.youhappygo.service.CustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("admin/customer")
@Tag(name = "客户管理", description = "客户管理")
public class CustomerController {

    @Autowired
    CustomerService customerService;

    @GetMapping("/getAllCustomer/{pageNum}/{pageSize}")
    @Operation(summary = "直接查询所有的客户的简略信息",description = "直接查询所有的客户的简略信息")
    public Result<PageInfo<CustomerVo>> getAllCustomer(@PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        List<CustomerVo> customerVoList = customerService.getAllCustomer(pageNum, pageSize);
        PageInfo<CustomerVo> pageInfo = new PageInfo(customerVoList);
        return Result.build(pageInfo, ResultCode.SUCCESS);
    }

    @GetMapping("/getCustomerInfoById/{userId}")
    @Operation(summary = "根据ID查询客户的详细信息",description = "根据ID查询客户的详细信息")
    public Result<CustomerDetailVo> getCustomerInfoById(@PathVariable Integer userId) {
        CustomerDetailVo customerVo = customerService.getCustomerInfoById(userId);
        return Result.build(customerVo, ResultCode.SUCCESS);
    }

}
